using System.Collections.Generic;
using abilities.effects;
using LitJson;

namespace abilities.templates
{
    public class EffectSpawnEffectsTemplate : EffectTemplate
    {
        private List<EffectTemplate> effects = new();

        public EffectSpawnEffectsTemplate() : base()
        {
        }

        public override Effect CreateInstance(int level)
        {
            return new EffectSpawnEffects(this, level);
        }

        public override bool FromJson(JsonData value)
        {
            if (!base.FromJson(value))
                return false;

            if (value.ContainsKey("effects"))
            {
                foreach (JsonData i in value["effects"])
                {
                    EffectTemplate effect = EffectTemplate.ParseJson(i);
                    if (effect != null)
                        effects.Add(effect);
                }
            }

            return true;
        }

        public List<EffectTemplate> GetEffects()
        {
            return effects;
        }
    }
}